﻿using M_Process.API.Appliction.Command.ProcessTasksCommand;
using M_Process.Domain;
using M_Process.Repository.ProcessImpl;
using M_Process.Repository.ProcessInterface;
using MediatR;

namespace M_Process.API.Appliction.CommandHandlers.ProcessTasksCommandHandler
{
    public class ReverseFillingProcessTasksCommandHandler : IRequestHandler<ReverseFillingProcessTasksCommand, ProcessTasks>
    {
        /// <summary>
        /// 工序任务仓储接口
        /// </summary>
        protected readonly IProcessTasksRepository processTasksRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="processTasksRepository">工序任务仓储接口</param>
        public ReverseFillingProcessTasksCommandHandler(IProcessTasksRepository processTasksRepository)
        {
            this.processTasksRepository = processTasksRepository;
        }

        /// <summary>
        /// 反填充工序任务
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ProcessTasks> Handle(ReverseFillingProcessTasksCommand request, CancellationToken cancellationToken)
        {
            return await processTasksRepository.GetModelsAsync(request.ProcessTasksId);
        }
    }
}
